    function $(id){
		return document.getElementById(id);
	};
	function addlist(arr,to){
		var Option = $(to);
		Option.options.length=0;
		for (var i=0;i<arr.length ;i++ ){
			var op = document.createElement("option");
			op.value = arr[i];
			op.innerHTML = arr[i];
			Option.appendChild(op);
		}
	};
	function searchIndex(value,opid){
		var op=$(opid);
		for (var i=0;i<op.options.length ;i++ ){
			if (op.options[i].value==String(value)){
				op.options[i].selected=true;
				return;
			}
		}
		op.options[0].selected=true;
		return;
	};
	function importlists(){
		addlist(buffs.property(),'lists');
		addlist(stat_types.property(),'stat_type');
		addlist([''],'stat_sub_type');
		addlist(rule_types.property(),'rule_type');
		addlist([true,false],'is_false_rule');
		addlist([''],'string');
	};
	function attach(){
		$('lists').onchange=function(){
			$('id').value=this.value;
		};
		$('import').onclick=function(){
			var id = $("id").value;
			if (!id){
				id=buffs.property().random();
				searchIndex(id,'lists');
			}
			viewbuff(buffs[id]);
		};
		$('outport').onclick=function(){
			$('content').value=js_beautify(JSON.stringify(outport()));
		};
		$('save').onclick=function(){
			buffs[$('id').value]=outport();
			addlist(buffs.property(),'lists');
		};
		$("localization").onclick=function(){
			var arr=[];
			var p = buffs.property();
			for (var i=0;i<p.length ;i++ ){
				arr.push(JSON.stringify(buffs[p[i]]));
			}
			$('content').value=js_beautify('{"buffs":['+arr+']}');
		};
		$('new').onclick=newbuff;
		$('stat_type').onchange=function(){
			addlist(stat_types[this.value],'stat_sub_type');
		};
		$('rule_type').onchange=function(){
			addlist([''],'string');
			$('float').value=0;
			typeof rule_types[this.value] == 'number'?$('float').value=rule_types[this.value]:this;
			typeof rule_types[this.value] == 'object'?addlist(rule_types[this.value],'string'):this;
		};
	};
	function viewbuff(buff){
		$('id').value=buff.id;
		searchIndex(buff.stat_type,'stat_type');
		$('stat_type').onchange()
		searchIndex(buff.stat_sub_type,'stat_sub_type');
		searchIndex(buff.rule_type,'rule_type');
		searchIndex(buff.is_false_rule,'is_false_rule');
		$('amount').value=buff.amount;
		$('rule_type').onchange();
		$('float').value=buff.rule_data.float;
		searchIndex(buff.rule_data.string,'string');
	};
	function outport(){
		var json = {
			id : $('id').value,
			stat_type : $('stat_type').value,
			stat_sub_type : $('stat_sub_type').value,
			amount : Number($('amount').value),
			rule_type : $('rule_type').value,
			is_false_rule : $('is_false_rule').value=='true',
			rule_data : {
				float : Number($('float').value),
				string : $('string').value
			} 
		};
		return json;
	};
	function newbuff(){
		var str = new buff().string;
		viewbuff(JSON.parse(str))
	}
	window.onload=function(){
		importlists();
		attach();
	}